#!/sbin/openrc-run

name="Sentinel-minipot"
description="A minimal honeypot that emulates Telnet, HTTP, FTP and SMTP network services"

: ${command_user:="sentinel-minipot"}
: ${sentinel_socket="ipc:///run/sentinel_pull.sock"}
: ${syslog:="yes"}

command="/usr/bin/sentinel-minipot"
command_args="
	${ftp_port:+"--ftp=$ftp_port"}
	${http_port:+"--http=$http_port"}
	${smtp_port:+"--smtp=$smtp_port"}
	${telnet_port:+"--telnet=$telnet_port"}
	${mqtt_topic:+"--topic=$mqtt_topic"}
	${sentinel_socket:+"--socket=$sentinel_socket"}
	${logfile:+"--log-file=$logfile"}
	${loglevel:+"--log-level=$loglevel"}
	$command_args
	"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"

depend() {
	need net
	use sentinel-proxy
	after firewall
}

start_pre() {
	yesno "${syslog-}" && command_args="$command_args --syslog"

	if [ "${logfile-}" ]; then
		checkpath -f -m 640 -o "$command_user" "$logfile" || return 1
	fi
}
